<?php 
/***
    Amrita ITEWS - Copyright (C) 2009 Amrita Vishwa Vidyapeetham, Amritapuri.
                                     (http://www.amrita.edu)
    ***************************************************************************
    This file is part of the Amrita ITEWS distribution.
    Amrita ITEWS is free software; you can redistribute it and/or modify it 
    under the terms of the GNU General Public License (version 2) as published 
    by the Free Software Foundation AND MODIFIED BY the Amrita ITEWS exception.
    ***NOTE*** The exception to the GPL is included to allow you to distribute
    a combined work that includes Amrita ITEWS without being obliged to provide
    the source code for proprietary components outside of the Amrita ITEWS
    software. Amrita ITEWS is distributed in the hope that it will be useful, 
    but WITHOUT ANY WARRANTY; without even the implied warranty of 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
    Public License for more details. You should have received a copy of the GNU
    General Public License and the Amrita ITEWS license exception along with 
    Amrita ITEWS if not then it can be viewed here: 
    http://itews.amrita.ac.in/license.html.
    
    Documentation, latest information, license and contact details are at:
    http://itews.amrita.ac.in/
 
    Amrita ITEWS source code can be found at:
    http://code.google.com/p/itews"; 
    
    The initial code-base of Amrita ITEWS was developed by Amrita Vishwa 
    Vidyapeetham as part of the project titled,\"Intelligent & Interactive 
    Telematics using Emerging Wireless Technologies for Transport Systems 
    (ITEWS)\" sponsored by Technology Information Forecasting and Assessment 
    Council (TIFAC), India.
***/
?><?php
// Setting the Content-Type header with charset
header('Content-Type: text/html; charset=utf-8');
require_once("./utils.php.inc");
require_once("./settings.php.inc");
//require_once("./error_handler.php");
session_start();
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
    font: Verdana,Arial,sans-serif;
	 /* An explicit background color is required for Safari. */
	 /* Otherwise your corner chunks will come out black!    */
	background: #000055;
	Overflow:hidden
}
div.main {width:100%;text-align:center;overflow:auto}
div.section { clear: left; }
h1 { font-size: 150%; padding: 0 }
h2 { background: #ccc; padding: 1px 20px;  }
div.demo {
	float: left; width: 3.5em; padding: 33px; margin: 0.5em; font-size:15pt;
    background: #EEF; color:#000; text-align: center; font-family: verdana, arial, sans-serif;
}
div.demoS {
	float: left; width: 3.5em; padding: 33px; margin: 0.1em; font-size:15pt;
    background: #FF0; color:#000; text-align: center; font-family: verdana, arial, sans-serif;
}
div.demoT {
	width: 6em; padding: 7px; margin: 0.5em; font-size:15pt;
    background: #F00; color:#FFF; text-align: center; font-family: verdana, arial, sans-serif;
}
div.fun  { margin: 2px; }
a {text-decoration:none;}
html { overflow: hidden; }



#light {
z-index:1;
position:fixed;
display:none;
visibility:hidden;
}
.text {
position:relative;
z-index:3;
}

       #flash { position: fixed; top: 0px; left: 0px; width: 100%; z-index: 1000; background-color: #569; color: white; border-bottom: 1px solid #555; font-family:arial,verdana}
           #flash, #flash * { cursor: pointer; }
           #flash .yui-b { padding: 5px 0; }
           #flash .yui-b>* { font-size: 128%; }
           #flash label { display: block; text-align: center; font-weight: bold; text-transform: capitalize; }
           /*#flash label:before { content: '"'; }
		   #flash label:after { content: '"'; }*/
           #flash.subtle { background-color: #444; color: white; }
           #flash.subtle:hover { background-color: #222; }
           #flash.warning { background-color: #ff0; color: black; }
           #flash.warning:hover { background-color: #ff8; }
           #flash.success { background-color: #595; }
           #flash.success:hover { background-color: #7b7; }
           #flash.failure, #flash.error { background-color: #800; }
           #flash.failure:hover, #flash.error:hover { background-color: #a00; }
           #flash.subtle, #flash.success, #flash.failure, #flash.error { text-shadow: black 2px 2px 2px; }

</style>
<!--link rel="stylesheet" href="thickbox.css" type="text/css" media="screen" /-->
<script type="text/javascript" src="jquery-1.2.3.js"></script>
<!--script type="text/javascript" src="thickbox.js"></script-->
<script type="text/javascript" src="jQuery.flash.js"></script>
<script type="text/javascript" src="jquery.corner.js"></script>
<script type="text/javascript">
	$(function(){	// shorthand for $(document).ready() BTW
        $('div.demo').each(function() {
			// The text of the paragraphs in the rounded divs is also the
			// jQuery code needed to create that effect. Cosmic.
             //eval($('p', this).text());
	$(this).corner("10px");
        });
        $('div.demoS').each(function() {
			$(this).corner("10px");
        });
        $('div.demoT').each(function() {
			$(this).corner("10px");
        });

		$('#routes').pager('div.main', {
      /**
	  prevText: '<img src="images/Buttons (7 icons)/button_previous.gif" border="0"/>',
	nextText: '<img src="images/Buttons (7 icons)/button_next.gif" border="0"/>'
	**/
		prevText: '<img src="images/previousO.png" border="0"/>',
		nextText: '<img src="images/nextO.png" border="0"/>'
    });

    $('#main p').wrap("<code></code>");


	});


function trakLight(e){

	var iet=function(){return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;},
	ev=e? e : window.event, posx = 0, posy = 0, l=document.getElementById('light'), good=1;

	if(l.tagName.toLowerCase()=='img'&&typeof l.complete=='boolean'&&!l.complete)
		good=0;
	else if(l.tagName.toLowerCase()=='img'&&typeof l.complete!='boolean'){
		alert('Your browser isn\'t capable of displaying this page as intended')
		good=0;
		trakLight.bad=1;
	}

	l.style.display=good? 'block' : 'none';

	if(typeof light!='undefined'&&light.tagName.toLowerCase=='div')
		light.style.display='block';

	//for (var els=document.getElementsByTagName('*'), i = els.length-1; i > -1; --i)
	//if(els[i].className=='text')
	//els[i].style.color=good? 'black' : 'white';
	///if(trakLight.bad){
	///document.onclick=null; //Added  - removed these, coz even if traklight is bad, the link should traverse
	///return;
	///}

	if (ev.pageX || ev.pageY) {
		posx = ev.pageX-pageXOffset;
		posy = ev.pageY-pageYOffset;
		if(window.opera){
			posx=Math.min(posx, pageXOffset+window.innerWidth-l.offsetWidth/2);
			posy=Math.min(posy, pageYOffset+window.innerHeight-l.offsetHeight/2);
		}
	}
	else if (ev.clientX || ev.clientY) {
		posx = ev.clientX + (l.style.position=='absolute'? iet().scrollLeft : 0);
		posy = ev.clientY + (l.style.position=='absolute'? iet().scrollTop : 0);
		if(l.style.position=='absolute'){
			posx=Math.min(posx, iet().scrollLeft+iet().clientWidth-l.offsetWidth/2);
			posy=Math.min(posy, iet().scrollTop+iet().clientHeight-l.offsetHeight/2);
		}
	}
	l.style.visibility = "visible"; //added 
	l.style.top=posy-l.offsetHeight/2+'px';
	l.style.left=posx-l.offsetWidth/2+'px';
	//$('#light').animate({opacity: 1.0}, 3000);
	//l.style.visibility = "hidden";
}
function clearLight(){
	document.getElementById('light').style.visibility='hidden';
}

if(document.images){
	document.write('<style type="text/css">.text {cursor:default;color:black;}#light {display:block;}<\/style>');
	document.onclick=trakLight;
	window.setInterval("clearLight()",1000);
}
</script>

  <!-- pager -->
  <style type="text/css">
  .routenumbers { border: 0px solid #666; margin: 0.5em 0; }
  .routenumbers p { padding: 0px; margin: 0; }
  .nav { background: #005; border-top: 0px solid #ccc; padding: 5px; text-align:center;vertical-align:top}
  .nav a { padding: 0 5px; font-size:30pt;vertical-align:top}
  .nav a.highlight { color: #fff; font-weight: bold; vertical-align:top}
  .nav a img{ vertical-align:middle}
  </style>

  <script type="text/javascript" src="jquery.pager.js"></script>

</head>
<body>
<?php
	$_SESSION['currentContext']="changeRoute";

if (isset($_GET['routeCode'])){
	//store it in the cookie

	//store it in the session variable
	$_SESSION['currentRoute'] = $_GET['routeCode']; // store session data

}
?>
<img id="light" alt="" src="images/light2.png">
		<div id="routes" class="routenumbers">
<?php

$error_occured = false;

$sql = "SET NAMES utf8";
if ( ($result = query_wrapper($sql, __FILE__, __LINE__))==null){
	//jQuery.flash.error('','310: System error! Please contact support');
	$error_occured = true;//used to check display of remaining body
}
else {
	$sql = "SELECT route_schedule_code as rsc FROM route_schedules ORDER BY route_schedule_code ASC";
	if ( ($result = query_wrapper($sql, __FILE__, __LINE__))==null){
		//jQuery.flash.error('','311: System error! Please contact support');
		$error_occured = true;//used to check display of remaining body
	}
}

$total_rsc = mysql_num_rows($result);
$i = 0;
if ($total_rsc > 0){
	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

		if ($i % 4 == 0){
			switch ($i){
				case 0:
					echo '<div class="main">'.
						'<div class="section">';
					break;
				default:
					echo '</div>'.
						'</div>';
					echo '<div class="main">'.
						'<div class="section">';
					break;
			}
		}

		//echo '<a href="changeroutescreen.php?routeCode='.$row["rsc"].'">';
		echo '<a href="javascript:top.location.href=\'./driver.php?routeCode='.$row["rsc"].'\'">';
		if ($row["rsc"]==$_SESSION['currentRoute'])
			echo '<div class="demoS">';
		else
			echo '<div class="demo">';

		echo '<B>'.strtoupper($row["rsc"]).'</B></div></a>';

		if ($i+1 == $total_rsc){
					echo '</div>'.
						'</div>';
		}
		$i++;
	}
}
?>
		</div>
</body>
